﻿//==========================================================
// 此代码由TilverNET代码生成工具自动生成，请不要修改
// 代码生成器核心库版本号：1.0
// 创建时间：2013/5/28 16:38:25
//==========================================================

using System;
using System.Text;
using System.Data;
using System.Data.Common;
using System.Collections.Generic;
using Tilver.Data;
using Tilver.Data.DataPager;

namespace Tilver.DAL.TilverDB.LANDY
{
    #region EO

    /// <summary>
    ///  《LANDY.P_GetCustomerInfo(实体类)》
    /// </summary>
    [Serializable]
    public class PGetCustomerInfoEO : IRowMapper<PGetCustomerInfoEO>
    {
        protected int? _cid;
        protected int? _cityId;
        protected string _userName;
        protected string _phone;
        protected string _address;
        protected DateTime? _recDate;
        protected byte? _cType;


        /// <summary>
        ///  《[字段]  []》
        /// </summary>
        public int? Cid
        {
            get { return _cid; }
            set { _cid = value; }
        }

        /// <summary>
        ///  《[字段]  []》
        /// </summary>
        public int? CityId
        {
            get { return _cityId; }
            set { _cityId = value; }
        }

        /// <summary>
        ///  《[字段]  []》
        /// </summary>
        public string UserName
        {
            get { return _userName; }
            set { _userName = value; }
        }

        /// <summary>
        ///  《[字段]  []》
        /// </summary>
        public string Phone
        {
            get { return _phone; }
            set { _phone = value; }
        }

        /// <summary>
        ///  《[字段]  []》
        /// </summary>
        public string Address
        {
            get { return _address; }
            set { _address = value; }
        }

        /// <summary>
        ///  《[字段]  []》
        /// </summary>
        public DateTime? RecDate
        {
            get { return _recDate; }
            set { _recDate = value; }
        }

        /// <summary>
        ///  《[字段]  []》
        /// </summary>
        public byte? CType
        {
            get { return _cType; }
            set { _cType = value; }
        }

        /// <summary>
        /// 默认构造函数
        /// </summary>
        public PGetCustomerInfoEO()
        {
        }

        /// <summary>
        /// 自定义构造函数
        /// </summary>
        /// <param name = "cid"></param>
        /// <param name = "cityId"></param>
        /// <param name = "userName"></param>
        /// <param name = "phone"></param>
        /// <param name = "address"></param>
        /// <param name = "recDate"></param>
        /// <param name = "cType"></param>
        public PGetCustomerInfoEO(int? cid, int? cityId, string userName, string phone, string address, DateTime? recDate, byte? cType)
        {
            _cid = cid;
            _cityId = cityId;
            _userName = userName;
            _phone = phone;
            _address = address;
            _recDate = recDate;
            _cType = cType;
        }


        /// <summary>
        /// 将结果集映射成实体对象
        /// </summary>
        /// <param name = "reader">只进结果集流</param>
        /// <return></return>
        public PGetCustomerInfoEO MapRow(IDataReader reader)
        {
            var ret = new PGetCustomerInfoEO();
            ret.Cid = (reader["Cid"] is DBNull) ? null : (int?)reader["Cid"];
            ret.CityId = (reader["CityId"] is DBNull) ? null : (int?)reader["CityId"];
            ret.UserName = (reader["UserName"] is DBNull) ? null : (string)reader["UserName"];
            ret.Phone = (reader["Phone"] is DBNull) ? null : (string)reader["Phone"];
            ret.Address = (reader["Address"] is DBNull) ? null : (string)reader["Address"];
            ret.RecDate = (reader["RecDate"] is DBNull) ? null : (DateTime?)reader["RecDate"];
            ret.CType = (reader["CType"] is DBNull) ? null : (byte?)reader["CType"];
            return ret;
        }

        /// <summary>
        /// 将结果集映射成实体对象，返回映射方法
        /// </summary>
        /// <return></return>
        public Func<IDataReader, PGetCustomerInfoEO> GetMapper()
        {
            return MapRow;
        }


    }


    #endregion
    #region  PO

    /// <summary>
    ///  《LANDY.P_GetCustomerInfo(逻辑类)》
    /// </summary>
    public class PGetCustomerInfoPO : DbManagerBase
    {
        private const string _procName = "[LANDY].[P_GetCustomerInfo]";

        /// <summary>
        /// 存储过程名称
        /// </summary>
        public string ProcName
        {
            get { return _procName; }
        }

        

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name = "routeData">路由数据</param>
        public PGetCustomerInfoPO(object routeData = null) : base(routeData) { }

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name = "connectionStringName">连接字符串名称</param>
        public PGetCustomerInfoPO(string connectionStringName) : base(DbDataFactory.Create(connectionStringName)) { }


        /// <summary>
        /// 存储过程操作对象
        /// </summary>
        /// <return></return>
        private DbAdoBase AdoBase()
        {
            return DataBase.CreateDbAdo(_procName, CommandType.StoredProcedure);
        }


        private int? _count;
        /// <summary>
        /// 
        /// </summary>
        /// <return></return>
        public int? GetCount()
        {
            return _count;
        }



        /// <summary>
        /// 执行存储过程并返回受影响的行数
        /// </summary>
        /// <param name = "count"></param>
        /// <param name="tm">事务管理对象</param>
        /// <return></return>
        public IEnumerable<PGetCustomerInfoEO> ExecList(int? count, TransactionManager tm = null)
        {
            var adoBase = AdoBase();
            var ret = adoBase
                .AddInOutParameter("@Count", count, DbType.Int32, 4)
                .ExecuteList(new PGetCustomerInfoEO().GetMapper(), tm);
            {
                var value = adoBase.Command.Parameters["@Count"].Value;
                _count = (value is DBNull) ? null : (int?)value;
            }
            return ret;
        }

    }


    #endregion
}
